﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using System.Threading;
namespace MMDemo
{
    //委托
    public delegate void DrawHandler();
    /// <summary>
    /// 顺序表操作的类型
    /// </summary>
    public enum ListOperateType
    {
        Insert = 0,
        Delete = 1,
        Search = 2, 
        Combination = 3,
    }
    /// <summary>
    /// 顺序表
    /// </summary>
    class AnimationList:InterfaceDataStructs
    {
        private const int DEFAULT_SPEED = 200;
        /// <summary>
        /// 顺序表的一些数据
        /// </summary>
        public struct SeqData
        {
          /// <summary>
          /// 删除或插入的位置(从1开始)
          /// </summary>
          public  int Pos;
          /// <summary>
          /// 数据一(初始化数据或合并的数据一)
          /// </summary>
          public  string Data_One;
          /// <summary>
          /// 数据二(插入的数据或合并的数据二)
          /// </summary>
          public string Data_Two;
          public void SetValues(int Pos, string Data_One, string Data_Two)
          {
              this.Pos = Pos;
              this.Data_One = Data_One;
              this.Data_Two = Data_Two;
          }
        }
        private const int MAX_RECT_WIDTH = 160;
        /// <summary>
        /// 执行的速度
        /// </summary>
        private int Speed = DEFAULT_SPEED;

        /// <summary>
        /// 操作的类型
        /// </summary>
        private ListOperateType OperateType = ListOperateType.Insert;
        /// <summary>
        /// 演示窗口的大小
        /// </summary>
        private Size An_Size = new Size(0, 0);
        /// <summary>
        /// 双缓冲画布
        /// </summary>
        public Bitmap Buffer_Bmp = null;
        /// <summary>
        /// 双缓冲Graphics
        /// </summary>
        private Graphics Buffer_Grap = null;
        /// <summary>
        /// DomeForm句柄
        /// </summary>
        private Form An_Form = null;
        /// <summary>
        /// 委托
        /// </summary>
        private DrawHandler RefreshHandler = null;
        /// <summary>
        /// 最多有多少个元素
        /// </summary>
        private const int MAX_SIZE = 26;
        /// <summary>
        /// 有多少个元素
        /// </summary>
        private int Number = 0;
        /// <summary>
        /// 元素矩形的大小 
        /// </summary>
        private Size Rect_Size = new Size(100, 50);
        /// <summary>
        /// 元素矩形图片
        /// </summary>
        private Bitmap[] Rect_Bmp;
        /// <summary>
        /// 位置箭头图片
        /// </summary>
        private Bitmap Pos_Bmp = null;
        /// <summary>
        /// 顺序表的数据
        /// </summary>
        private SeqData Seq_Data = new SeqData();
        /// <summary>
        /// 用于保存初始化数据
        /// </summary>
        private char[] data;
        /// <summary>
        /// 起始坐标
        /// </summary>
        private Point StartPt = new Point(100, 100);
        /// <summary>
        /// 当前元素的大小 
        /// </summary>
        private int Cur_Size = 0;
        /// <summary>
        /// 数据合并的值
        /// </summary>
        private string CombinateData = "";
        /// <summary>
        /// 合并数据一的索引
        /// </summary>
        private int OneIndex = -1;
        /// <summary>
        /// 合并数据二的索引
        /// </summary>
        private int TwoIndex = -1;
        /// <summary>
        /// 用来判断插入是否完成，如果完成就不显示插入的元素
        /// </summary>
        private bool IsInsertOver = false;
        /// <summary>
        /// 是元素查找还是索引查找
        /// </summary>
        private bool IsSearchIndex = false;
        private string SearchData = "";
        public AnimationList(Form An_Form, DrawHandler refreshHandler, int An_Width, int An_Height)
        {
            this.An_Form = An_Form;
            this.RefreshHandler = refreshHandler;
            this.An_Size.Width = An_Width;
            this.An_Size.Height = An_Height;
            LoadBitmapFromFile();
        }
        private void OnClick(object sender, EventArgs e)
        {
            MessageBox.Show("test");
        }
        /// <summary>
        /// 从文件中加载图片
        /// </summary>
        private void LoadBitmapFromFile()
        {
            Rect_Bmp = new Bitmap[4];
            //得到工程执行文件的目录
            String path = Application.StartupPath +"/image/";
            String[] name = {"seq_one.png", "seq_two.png", "seq_five.png", "seq_four.png"};
            for(int i = 0; i < 4; ++i)
            {
                Rect_Bmp[i] = (Bitmap)Image.FromFile(path + name[i]);
            }
            Pos_Bmp = (Bitmap)Image.FromFile(path + "/deletepos.png");
        }
        /// <summary>
        /// 设置演示窗口的大小
        /// </summary>
        public void SetAnimationFormSize(int Width, int Height)
        {
            this.An_Size.Width = Width;
            this.An_Size.Height = Height;
        }
        /// <summary>
        /// 根据演示窗口的宽度重新设置元素矩形的大小
        /// </summary>
        private void ResetElmentRectSize()
        {
            int max_elment_num = 0;
            switch (OperateType)
            {
                case ListOperateType.Insert:
                case ListOperateType.Delete:
                case ListOperateType.Search:
                    StartPt.Y = An_Size.Height / 2 - Rect_Size.Height / 2;
                    max_elment_num = data.Length; break;
                case ListOperateType.Combination:
                    max_elment_num = Seq_Data.Data_One.Length > Seq_Data.Data_Two.Length ? Seq_Data.Data_One.Length : Seq_Data.Data_Two.Length; break;
            }
            Rect_Size.Width = An_Size.Width/ max_elment_num;
            //如果元素矩形的宽度不能超过最大值
            if (Rect_Size.Width > MAX_RECT_WIDTH)
            {
                Rect_Size.Width = MAX_RECT_WIDTH;
            }
            Rect_Size.Height = Rect_Size.Width / 2;

            StartPt.X = (An_Size.Width - max_elment_num * Rect_Size.Width) / 2;
        }
        /// <summary>
        /// 重新设置双缓冲
        /// </summary>
         public void ResetBuffer(int Width, int Height)
         {
             SetAnimationFormSize(Width, Height);
             if (null != Buffer_Bmp)
             {
                 Buffer_Bmp.Dispose();
                 Buffer_Bmp = null;
             }
             if (null != Buffer_Grap)
             {
                 Buffer_Grap.Dispose();
                 Buffer_Grap = null;
             }
             Buffer_Bmp = new Bitmap(this.An_Size.Width, this.An_Size.Height);
             Buffer_Grap = Graphics.FromImage(Buffer_Bmp);
             ResetElmentRectSize();
             switch (OperateType)
             {
                 case ListOperateType.Insert:
                     ShowInitData(StartPt.X, StartPt.Y, data, 3, Cur_Size);
                     if (!IsInsertOver)
                     DrawElment(StartPt.X +(Seq_Data.Pos - 1)*Rect_Size.Width, StartPt.Y - Rect_Size.Height, Seq_Data.Data_Two[0], 0); break;
                 case ListOperateType.Delete:
                     ShowInitData(StartPt.X, StartPt.Y, data, 3, Cur_Size);break;
                 case ListOperateType.Search:
                     ShowSearchData(StartPt.X, StartPt.Y, data, 3, Cur_Size, -1); break;
                 case ListOperateType.Combination:
                     ShowCombinateData();break;
             }
         }
        /// <summary>
        /// 动画演示
        /// </summary>
        public void Animation()
        {
            switch (OperateType)
            {
                case ListOperateType.Insert:
                    Insert(); break;
                case ListOperateType.Delete:
                    Delete(); break;
                case ListOperateType.Combination:
                    Combinate(); break;
                case ListOperateType.Search:
                    Search(); break;
            }
             SysMainForm.AnimationForm.ChangeExcuteOverBtnsEnable();
        }
        /// <summary>
        /// 设置算法的执行的第几行
        /// </summary>
        private void SetExcuteLine(int line)
        {
            Thread.Sleep(Speed);
            SysMainForm.AnimationForm.SetSelectLine(line);
        }
        /// <summary>
        /// 画元素
        /// </summary>
        private void DrawElment(int x, int y, char data, int bmp_index)
        {
            Buffer_Grap.DrawImage(Rect_Bmp[bmp_index], x, y, Rect_Size.Width, Rect_Size.Height);
            //根据元素矩形的大小，比例缩小字体大小
            float fontSize = (float)(0.6*Rect_Size.Height);
            Buffer_Grap.DrawString(data.ToString(), new Font("微软雅黑", fontSize, FontStyle.Bold), Brushes.Red, x, y);
        }
        private void ShowInitData(int x, int y, char[] data, int bmp_index, int size)
        {
                Buffer_Grap.DrawImage(PublicDataClass.DemoPicture, 0, 0, An_Size.Width, An_Size.Height);
                DrawInitData(x, y, data, bmp_index, size); 
        }
        /// <summary>
        /// 画数据
        /// </summary>
        private void DrawInitData(int x, int y, char[] data, int bmp_index, int size)
        {
            for (int i = 0; i < size; ++i)
            {
                DrawElment(x, y, data[i], bmp_index);
                x += Rect_Size.Width;
            }
            //指出要删掉的位置
            if (OperateType == ListOperateType.Delete)
            {
                Buffer_Grap.DrawImage(Pos_Bmp, 
                    StartPt.X + (Seq_Data.Pos - 1) * Rect_Size.Width + Rect_Size.Width / 2 - Pos_Bmp.Width / 2, StartPt.Y - Pos_Bmp.Height);
            }
        }
        /// <summary>
        /// 往后移动元素，用于插入
        /// </summary>
        private void  MoveElmentBack()
        {
            int MoveIndex = Seq_Data.Data_One.Length - 2;
            int x = MoveIndex * Rect_Size.Width + StartPt.X;
            int y = StartPt.Y;
            int Step = 0;
            SetExcuteLine(8);
            while (true)
            {
                SetExcuteLine(10);
                //画所有的元素
                ShowInitData(StartPt.X, y, data, 3, Cur_Size);
                //画要插入的元素
                DrawElment((Seq_Data.Pos - 1) * Rect_Size.Width + StartPt.X, y - Rect_Size.Height, Seq_Data.Data_Two[0], 0);
                //画移动的元素
                DrawElment(x + Step, y, Seq_Data.Data_One[MoveIndex], 2);
                Step += 10;
                if (Step > Rect_Size.Width)//判断一个元素是否移动完
                {
                        //画所有的元素
                        ShowInitData(StartPt.X, y, data, 3, Cur_Size);
                         //画要插入的元素
                        DrawElment((Seq_Data.Pos - 1) * Rect_Size.Width + StartPt.X, y - Rect_Size.Height, Seq_Data.Data_Two[0], 0);
                        DrawElment(x + Rect_Size.Width, y, Seq_Data.Data_One[MoveIndex], 2);
                        Refresh();
                        data[MoveIndex + 1] = data[MoveIndex];
                        --MoveIndex;
                        Step = 0;
                        x = MoveIndex * Rect_Size.Width + StartPt.X;
                        SetExcuteLine(8);
                        if (MoveIndex < Seq_Data.Pos - 1)//判断元素是否移到了要插入的元素
                        {
                            x = (Seq_Data.Pos - 1) * Rect_Size.Width;
                            Refresh();
                            return;
                        }
               }
               Refresh();
            }
        }
        /// <summary>
        /// 移动要插入的元素，用于插入
        /// </summary>
        private void MoveInsertElment()
        {
            int x = StartPt.X + (Seq_Data.Pos - 1) * Rect_Size.Width;
            int y = StartPt.Y - Rect_Size.Height;
            int Step = 0;
            while (true)
            {
                SetExcuteLine(12);
                ShowInitData(StartPt.X, StartPt.Y, data, 3, Cur_Size);
                DrawElment(x, y + Step, Seq_Data.Data_Two[0], 0);
                if (Step >= Rect_Size.Height)
                {
                    ShowInitData(StartPt.X, StartPt.Y, data, 3, Cur_Size);
                    DrawElment(x, y + Rect_Size.Height, Seq_Data.Data_Two[0], 0);
                    data[Seq_Data.Pos - 1] = Seq_Data.Data_Two[0];
                    Refresh();
                    SetExcuteLine(13);
                    SetExcuteLine(14);
                    return;
                }
                Refresh();
                Step += 5;
            }
        }
        /// <summary>
        /// 动画演示顺序表的插入
        /// </summary>
        private void Insert()
        {
            SetExcuteLine(3);
            if (Seq_Data.Pos < 1 || Seq_Data.Pos > Seq_Data.Data_One.Length)
            {
                SetExcuteLine(5);
                MessageBox.Show(An_Form, "插入的位置越界!");
                SetExcuteLine(6);
                return;
            }
            IsInsertOver = false;
            MoveElmentBack();
            MoveInsertElment();
            IsInsertOver = true;
            Thread.Sleep(Speed);
            ShowInitData(StartPt.X, StartPt.Y, data, 3, Cur_Size);
            Refresh();
            SetExcuteLine(15);
            MessageBox.Show(An_Form, "演示结束");
        }
        private void ShowSearchData(int x, int y, char[] data, int bmp_index, int size, int moveIndex)
        {
            string  str_explain = "";
            if (IsSearchIndex)
            {
                str_explain += "按位查找，位值：" + SearchData;
            }
            else
            {
                str_explain += "元素查找，元素值：" + SearchData;
            }
            Buffer_Grap.DrawString(str_explain, new Font("微软雅黑", 15), Brushes.Red, x, 30);
            for (int i = 0; i < size; ++i)
            {
                int temp = bmp_index;
                if (i == moveIndex)
                {
                    temp = 0;
                }
                DrawElment(x, y, data[i], temp);
                x += Rect_Size.Width;
            }
        }
        /// <summary>
        /// 元素查找 
        /// </summary>
        private void SearchElment()
        {
            int i = 0;
            SetExcuteLine(3); 
            SetExcuteLine(5);
            SetExcuteLine(6);
            while (i <= data.Length - 1)
            {
                SetExcuteLine(8);
                if ( i >= 0 &&SearchData[0] == data[i])
                {
                    SetExcuteLine(10);
                    ShowSearchData(StartPt.X, StartPt.Y, data, 3, Cur_Size, i);
                    Refresh();
                    MessageBox.Show( An_Form, "元素已查找到");
                    return;
                }
                ShowSearchData(StartPt.X, StartPt.Y, data, 3, Cur_Size, i);
                Refresh();
                SetExcuteLine(6);
                ++i;
            }
            SetExcuteLine(27);
            MessageBox.Show(An_Form, "查找的元素不存在");
        }
        /// <summary>
        /// 索引查找
        /// </summary>
        private void SearchIndex()
        {
            int i = -1;
            int SearchIndex = Convert.ToInt32(SearchData);
            SetExcuteLine(3);
            SetExcuteLine(13);
            SetExcuteLine(14);
            if (SearchIndex < 0 || SearchIndex > 8)
            {
                SetExcuteLine(16);
                MessageBox.Show(An_Form, "查找失败！");
                return;
            }
            SetExcuteLine(18);
            while (i <= data.Length - 1 && i <= SearchIndex)
            {
                Thread.Sleep(Speed * 2);
                SetExcuteLine(20);
                if (i +1 == SearchIndex)
                {
                    SetExcuteLine(22);
                    MessageBox.Show(An_Form, "元素索引已查找到");
                    return;
                }
                else
                {
                    ++i;
                }
                ShowSearchData(StartPt.X, StartPt.Y, data, 3, Cur_Size, i);
                Refresh();
                SetExcuteLine(18);
            }
            MessageBox.Show(An_Form, "查找的索引超过元素大小");
        }
        /// <summary>
        /// 查找
        /// </summary>
        private void Search()
        {
            if (IsSearchIndex)
            {
                if (Convert.ToInt32(SearchData) < 0)
                {
                    MessageBox.Show("查找的索引为负数,演示结束!");
                    return;
                }
                SearchIndex();
            }
            else
            {
                SearchElment();
            }
        }
        /// <summary>
        /// 元素向前移动，用于删除
        /// </summary>
        private void MoveElmentForward()
        {
            int MoveIndex = Seq_Data.Pos;
            int x = MoveIndex * Rect_Size.Width + StartPt.X;
            int y = StartPt.Y;
            int Step = 0;
            SetExcuteLine(8);
            while (true)
            {
                SetExcuteLine(10);
                //画所有的元素
                ShowInitData(StartPt.X, y, data, 3, Cur_Size);
                //画移动的元素
                DrawElment(x - Step, y, Seq_Data.Data_One[MoveIndex], 2);
                Refresh();
                Step += 10;
                if (Step > Rect_Size.Width)//判断一个元素是否移动完
                {
                    //画所有的元素
                    ShowInitData(StartPt.X, y, data, 3, Cur_Size);
                    //画移动的元素
                    DrawElment(x - Rect_Size.Width, y, Seq_Data.Data_One[MoveIndex], 2);
                    Refresh();
                    SetExcuteLine(8);
                    data[MoveIndex - 1] = data[MoveIndex];
                    ++MoveIndex;
                    Step = 0;
                    x = MoveIndex * Rect_Size.Width + StartPt.X;
                    if (MoveIndex > data.Length - 1)//判断元素是否移到了要插入的元素
                    {
                        --Cur_Size;
                        SetExcuteLine(12);
                        SetExcuteLine(13);
                        return;
                    }
                }
            }
        }
        /// <summary>
        /// 删除
        /// </summary>
        private void Delete()
        {
            SetExcuteLine(3);
            if (Seq_Data.Pos < 1 || Seq_Data.Pos > Seq_Data.Data_One.Length)
            {
                SetExcuteLine(5);
                MessageBox.Show(An_Form, "删除的位置越界!");
                SetExcuteLine(6);
                return;
            }
            MoveElmentForward();
            ShowInitData(StartPt.X, StartPt.Y, data, 3, Cur_Size);
            Refresh();
            SetExcuteLine(14);
            MessageBox.Show(An_Form, "演示结束");
        }
        /// <summary>
        /// 只有序顺序数据才能合并，所合并前对合并数据进行排序
        /// </summary>
        private void SortCombinateData()
        {
            char[] com_one = Seq_Data.Data_One.ToCharArray();
            char[] com_two = Seq_Data.Data_Two.ToCharArray();
            Array.Sort(com_one);
            Array.Sort(com_two);
            Seq_Data.Data_One = new string(com_one);
            Seq_Data.Data_Two = new string(com_two);
        }
        /// <summary>
        /// 闪烁元素
        /// </summary>
        /// <param name="flickerNum">闪烁的次数</param>
        /// <param name="flag">是合并数据一，还是合并数据二</param>
        private void FlickerElment(int flickerNum, int index, int flag)
        {
            char data = '\0';
            int x = StartPt.X,  y = StartPt.Y;
            switch(flag)
            {
                case 1:
                    data = Seq_Data.Data_One[index];
                    break;
                case 2:
                    data = Seq_Data.Data_Two[index];
                    y += 200;
                    break;
            }
            for (int i = 0; i < flickerNum; ++i)
            {
                Thread.Sleep(Speed);
                ShowCombinateData();
                if (i % 2 == 0)
                {
                    DrawElment(x + index * Rect_Size.Width, y, data, 2);
                }
                Refresh();
            }
        }
        private void DrawCominatedata(int x, int y, char[] data, int bmp_index, int index)
        {
            int lineElmentNum = (An_Size.Width - StartPt.X*2) / Rect_Size.Width;
            int tempIndex = bmp_index;
            int tempX = x;
            for (int i = 0; i < data.Length; ++i)
            {
                if (i < index)
                {
                    tempIndex = 0;
                }
                else
                {
                    tempIndex = bmp_index;
                }
                DrawElment(x, y, data[i], tempIndex);
                if ((i + 1) % lineElmentNum == 0)
                {
                    x = StartPt.X;
                    y += Rect_Size.Height + 10;
                }
                else
                {
                     x += Rect_Size.Width;
                }
               
            }
        }
        private void ShowCombinateData()
        {
            Buffer_Grap.DrawImage(PublicDataClass.DemoPicture, 0, 0, An_Size.Width, An_Size.Height);
            DrawCominatedata(StartPt.X, StartPt.Y, Seq_Data.Data_One.ToCharArray(), 3, OneIndex);
            DrawCominatedata(StartPt.X, StartPt.Y + 200, Seq_Data.Data_Two.ToCharArray(), 3, TwoIndex);
            DrawCominatedata(StartPt.X, StartPt.Y + 400, CombinateData.ToCharArray(), 0, -1);
        }
        /// <summary>
        /// 闪烁二个比较的元素
        /// </summary>
        private void FlickerCompareElment(int oneIndex, int twoIndex)
        {
            for (int i = 0; i < 6; ++i)
            {
                SetExcuteLine(8);
                ShowCombinateData();
                if (i % 2 == 0)
                {
                    DrawElment(StartPt.X + oneIndex * Rect_Size.Width, StartPt.Y, Seq_Data.Data_One[oneIndex], 2);
                    DrawElment(StartPt.X + twoIndex * Rect_Size.Width, StartPt.Y + 200, Seq_Data.Data_Two[twoIndex], 2);
                }
                Refresh();
            }
        }
        /// <summary>
        /// 合并
        /// </summary>
        private void Combinate()
        {
            OneIndex = 0;
            TwoIndex = 0;
            StartPt.Y = 100;
            SetExcuteLine(6);
            while (OneIndex < Seq_Data.Data_One.Length && TwoIndex < Seq_Data.Data_Two.Length)
            {
                FlickerCompareElment(OneIndex, TwoIndex);
                if (Seq_Data.Data_One[OneIndex] <= Seq_Data.Data_Two[TwoIndex])
                {
                    SetExcuteLine(10);
                    FlickerElment(4, OneIndex, 1);
                    CombinateData += Seq_Data.Data_One[OneIndex++];
                }
                else
                {
                    SetExcuteLine(14);
                    FlickerElment(4, TwoIndex, 2);
                    CombinateData += Seq_Data.Data_Two[TwoIndex++];
                }
                SetExcuteLine(6);
            }
            //如果数据一还有没有合并的数据，则合并剩余的
            SetExcuteLine(17);
            while (OneIndex < Seq_Data.Data_One.Length)
            {
                SetExcuteLine(19);
                FlickerElment(4, OneIndex, 1);
                CombinateData += Seq_Data.Data_One[OneIndex++];
                SetExcuteLine(17);
            }
            //如果数据二还有没有合并的数据，则合并剩余的
            SetExcuteLine(21);
            while (TwoIndex < Seq_Data.Data_Two.Length)
            {
                SetExcuteLine(23);
                FlickerElment(4, TwoIndex, 2);
                CombinateData += Seq_Data.Data_Two[TwoIndex++];
                SetExcuteLine(21);
            }
            SetExcuteLine(24);
            ShowCombinateData();
            Refresh();
            SetExcuteLine(25);
            MessageBox.Show(An_Form, "演示结束");
        }
        /// <summary>
        /// 刷新DomeForm窗口
        /// </summary>
        private bool Refresh()
        {
            try
            {
                if(An_Form.IsHandleCreated)
                An_Form.Invoke(RefreshHandler);
            }
            catch(Exception ex) 
            { 
                MessageBox.Show(ex.Message); 
                return false;
            }
            return true;
        }
        public void InitData()
        {
            CombinateData = "";
            OneIndex = -1;
            TwoIndex = -1;
            Seq_Data.SetValues(PublicDataClass.LocateData, PublicDataClass.InitData, PublicDataClass.InsertData);
            OperateType = GlobalList.Operate_Type;
            if (OperateType == ListOperateType.Insert)
            {
                Seq_Data.Data_One +=  "?";
            }
            data = Seq_Data.Data_One.ToCharArray();
            //如果是合并，对数据就行排序
            if (OperateType == ListOperateType.Combination)
            {
                SortCombinateData();
            }
            Cur_Size = data.Length;
            if (OperateType == ListOperateType.Search)
            {
                IsSearchIndex = PublicDataClass.IsSearchForIndex;
                SearchData = PublicDataClass.SearchData;
            }
            ResetBuffer(An_Size.Width, An_Size.Height);
            Refresh();
        }
        public void ResetData()
        {
            IsInsertOver = false;
            OneIndex = -1;
            TwoIndex = -1;
            data = Seq_Data.Data_One.ToCharArray();
            Cur_Size = data.Length;
            CombinateData = "";
            switch (OperateType)
            {
                case ListOperateType.Insert:
                    ShowInitData(StartPt.X, StartPt.Y, data, 3, Cur_Size);
                    if(!IsInsertOver)
                    DrawElment(StartPt.X + (Seq_Data.Pos - 1) * Rect_Size.Width, StartPt.Y - Rect_Size.Height, Seq_Data.Data_Two[0], 0); break;
                case ListOperateType.Delete:
                    ShowInitData(StartPt.X, StartPt.Y, data, 3, Cur_Size); break;
                case ListOperateType.Combination:
                    ShowCombinateData(); break;
                case ListOperateType.Search:
                    ShowSearchData(StartPt.X, StartPt.Y, data, 3, Cur_Size, -1); break;
            }
            Refresh();
        }
        public Bitmap GetBufferBmp()
        {
            return Buffer_Bmp;
        }
        public void SetSpeed(float scale)
        {
            Speed = (int)(DEFAULT_SPEED * scale);
        }
    }
}
